#!/usr/bin/python3.8.9
# -*- coding: utf-8 -*-

# @Author  : Tina Yu
# @Time    : 2021-11-23 11:59
import os

from selenium import webdriver
from selenium.webdriver.chrome.options import Options


class Base:

    def setup(self):
        option = Options()
        option.debugger_address = "localhost:9222"
        browser = os.getenv("browser")
        print(f'环境获取的浏览器类型为：{browser}')
        if browser == "firefox":
            self.driver = webdriver.Firefox(options=option)
        elif browser == "headless":
            self.driver = webdriver.PhantomJs(options=option)
        else:
            # self.driver = webdriver.Chrome(options=option)
            self.driver = webdriver.Chrome()
        self.driver.implicitly_wait(3)
        self.driver.maximize_window()

    def teardown(self):
        self.driver.quit()